{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from xgboost import XGBRFRegressor as XGBR\n",
    "from numpy import *\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.linear_model import LinearRegression as LinearRegression\n",
    "from sklearn.model_selection import KFold,cross_val_score as CVS,train_test_split as TTS\n",
    "from sklearn.metrics import mean_squared_error as MSE\n",
    "wine = pd.read_excel(\"RF_lgb_Relation.xlsx\",header=0)\n",
    "wine0 = pd.read_csv(\"after_process_database.csv\",header=0)\n",
    "feature20 = pd.read_csv(\"final_features.csv\",header=0)\n",
    "feature_20=feature20.loc[:,'name'].values\n",
    "after_feature=wine.loc[:49,'Rela删除后的RF'].values\n",
    "index50 = wine0.loc[:,after_feature].values\n",
    "index20 = wine0.loc[:,feature_20].values\n",
    "yList = wine0.pIC50.values\n",
    "index20.shape"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "(1974, 20)"
      ]
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "source": [
    "reg1= XGBR(n_estimator = 150)\n",
    "MAE=CVS(reg1,index20,yList,cv=5,scoring='neg_mean_absolute_error')#只在训练集上，更严谨"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "[23:01:30] WARNING: ../src/learner.cc:573: \n",
      "Parameters: { \"n_estimator\" } might not be used.\n",
      "\n",
      "  This may not be accurate due to some parameters are only used in language bindings but\n",
      "  passed down to XGBoost core.  Or some parameters are not used but slip through this\n",
      "  verification. Please open an issue if you find above cases.\n",
      "\n",
      "\n",
      "[23:06:29] WARNING: ../src/learner.cc:573: \n",
      "Parameters: { \"n_estimator\" } might not be used.\n",
      "\n",
      "  This may not be accurate due to some parameters are only used in language bindings but\n",
      "  passed down to XGBoost core.  Or some parameters are not used but slip through this\n",
      "  verification. Please open an issue if you find above cases.\n",
      "\n",
      "\n",
      "[23:13:04] WARNING: ../src/learner.cc:573: \n",
      "Parameters: { \"n_estimator\" } might not be used.\n",
      "\n",
      "  This may not be accurate due to some parameters are only used in language bindings but\n",
      "  passed down to XGBoost core.  Or some parameters are not used but slip through this\n",
      "  verification. Please open an issue if you find above cases.\n",
      "\n",
      "\n",
      "[23:19:28] WARNING: ../src/learner.cc:573: \n",
      "Parameters: { \"n_estimator\" } might not be used.\n",
      "\n",
      "  This may not be accurate due to some parameters are only used in language bindings but\n",
      "  passed down to XGBoost core.  Or some parameters are not used but slip through this\n",
      "  verification. Please open an issue if you find above cases.\n",
      "\n",
      "\n",
      "[23:25:34] WARNING: ../src/learner.cc:573: \n",
      "Parameters: { \"n_estimator\" } might not be used.\n",
      "\n",
      "  This may not be accurate due to some parameters are only used in language bindings but\n",
      "  passed down to XGBoost core.  Or some parameters are not used but slip through this\n",
      "  verification. Please open an issue if you find above cases.\n",
      "\n",
      "\n"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "source": [
    "MSE.mean()"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "-1.0584267628963913"
      ]
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "metadata": {}
  }
 ],
 "metadata": {
  "orig_nbformat": 4,
  "language_info": {
   "name": "python",
   "version": "3.7.10",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.10 64-bit ('deeplearning': conda)"
  },
  "interpreter": {
   "hash": "a2441be928683876ab9582b799059e1f9f764e7f9dd2044f4d30ad5ffc1df7fc"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}